// import React, {useCallback, useMemo, useState, useReducer} from 'react';
import React,{useCallback, useMemo, useState, useReducer} from './ireact/react';
// import ReactDOM from 'react-dom';
import ReactDOM from './ireact/react-dom';

const ADD = 'ADD';
const MINUS = 'MINUS';

function reducer(state, action) {
  switch (action.type) {
  case ADD:
    return {number: state.number + 1}
  case MINUS:
    return {number: state.number - 1}
  default:
    return state;
  }
}

function Counter() {
  const [state,dispatch] = useReducer(reducer, {number: 0})

  return (
    <div>
      Counter: {state.number}
      <button onClick={()=>dispatch({type:ADD})}>+</button>
      <button onClick={()=>dispatch({type:MINUS})}>-</button>
    </div>
  )
}

ReactDOM.render(<Counter/>, document.getElementById('root'));
